package com.bj58.disconf.web.controllers;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bj58.disconf.web.common.constant.WebConstants;
import com.bj58.disconf.web.service.env.service.EnvMgr;
import com.bj58.disconf.web.service.env.vo.EnvListVo;
import com.bj58.disconf.web.utils.GuiceDI;
import com.bj58.wf.mvc.ActionResult;
import com.bj58.wf.mvc.annotation.Path;

/**
 * @author lemon
 * @version 2014-6-16
 */
@Controller
@RequestMapping(WebConstants.API_PREFIX + "/env")
@Path("/api/env")
public class EnvController extends BaseController {

    protected static final Logger LOG = LoggerFactory.getLogger(EnvController.class);

    private final EnvMgr envMgr = GuiceDI.getInstance(EnvMgr.class);

    /**
     * list
     *
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    @Path("/list")
    public ActionResult list() {
        try {
            List<EnvListVo> envListVos = envMgr.getVoList();

            return new JsonActionResult(buildListSuccess(envListVos, envListVos.size()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
